//
//  TodayVideoCollectionViewCell.m
//  SYiDaiy
//
//  Created by dllo on 16/9/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TodayVideoCollectionViewCell.h"
#import "UIView+Label.h"
#import "UIView+ImageView.h"
#import "TAMacro.h"
#import <AVFoundation/AVFoundation.h>
#import "Masonry.h"
@interface TodayVideoCollectionViewCell ()
@property (nonatomic,strong) AVPlayer *player;
@property (nonatomic,strong) AVPlayerItem *playerItem;
@property (nonatomic,strong) AVPlayerLayer *playerLayer;
@property (nonatomic,strong) UIView *background;
@property (nonatomic,strong) UISlider *slider;

@property (nonatomic,assign) CGFloat sumPlayOperation;
@property (nonatomic,assign) BOOL isClicked;


@end
@implementation TodayVideoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
//        _topView = [UIView new];
//        _topView.backgroundColor = [UIColor blackColor];
//        _topView.alpha = 0.3;
//        _underView = [UIView new];
//        _underView.backgroundColor = [UIColor blackColor];
//        _underView.alpha = 0.3;
       
        
        
//        self.background = [UIView new];
//        [self addSubview:self.background];
        
        _monthLabel = [UILabel new];
        _monthLabel.font = [UIFont systemFontOfSize:17];
        [self addSubview:_monthLabel];
        _monthLabel.numberOfLines = 0;
        _monthLabel.textColor = [UIColor blackColor];
        _monthLabel.alpha = 0.5;
        
        _titieLabel = [UILabel new];
        _titieLabel.font = [UIFont systemFontOfSize:17];
        [self addSubview:_titieLabel];
        
        _dayLabel = [UILabel new];
        _dayLabel.font = [UIFont systemFontOfSize:17];
        [self addSubview:_dayLabel];
        
        
        _sourceLabel = [UILabel new];
        _sourceLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:_sourceLabel];
        _sourceLabel.alpha = 0.5;
        _mainImageView = [UIImageView new];
        [self.background addSubview:_mainImageView];
        
       _playButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_playButton setImage:[UIImage imageNamed:@"ButtonPlayVideo"] forState:UIControlStateNormal];

        [self addSubview:_playButton];
       

    }
    return self;
}

- (void)layoutSubviews
{

    [_background mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(200);
        make.width.mas_equalTo(SCREEN_WIDTH);
    }];
    
    
    

    [_mainImageView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(SCREEN_HEIGHT - 200);

    }];
    
    CGFloat labelWidth = SCREEN_WIDTH / 375 * 50;
    CGFloat labelHeight = labelWidth * 3 / 5;


    [_dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(_mainImageView.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(labelWidth);
        make.height.mas_equalTo(labelHeight);
    }];
//
    [_monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_dayLabel.mas_left);
        make.top.mas_equalTo(_dayLabel.mas_bottom).mas_equalTo(0);
        make.width.mas_equalTo(_dayLabel.mas_width);
        make.height.mas_equalTo(_dayLabel.mas_height);
    }];
//
    [_titieLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_mainImageView.mas_bottom).mas_equalTo(10);
        make.left.mas_equalTo(_dayLabel.mas_right).mas_equalTo(10);
        make.right.mas_equalTo(10);
        make.height.mas_equalTo(_dayLabel.mas_height);
    }];
   
    [_sourceLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_titieLabel.mas_bottom).mas_equalTo(0);
        make.left.mas_equalTo(_monthLabel.mas_right).mas_equalTo(10);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(labelHeight);
    }];


    [_playButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(50);
        make.centerX.mas_equalTo(1);
        make.centerY.mas_equalTo(0.3);
    }];

    
}












- (void)awakeFromNib {
    // Initialization code
}

@end
